{template live_header}
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>
<style type="text/css">
    .bg{display:none;position:fixed;width:100%;height:100%;background:#000;z-index:2;top:0;left:0;opacity:0.7;}
</style>
<h4 style="padding-left:10px;;">
    <span>微课列表</span>
</h4>
<form class="form-horizontal" method="POST" action="?c=live_admin&a=getList"  >
    <div class="control-group search-group">
        <label class="control-label" >微课名称：</label>
        <div class="controls">
            <input type="text" value="{$name}" name="name" placeholder="微课标题" />
        </div>
    </div>

    <div class="control-group search-group">
        <label class="control-label" >状态：</label>
        <div class="controls">
            <select name="status" id="status">
                <option value="-999" {if $status == -999}selected{/if}>全部</option>
                {loop $arrStatus $k $v}
                <option value="$k" {if $status == $k}selected{/if}>$v</option>
                {/loop}
            </select>
            <input class="btn" type="submit" value="查询" />
            <a href="?c=live_admin&a=addLive" target="_blank"><button class="btn btn-primary" type="button">+新建微课</button></a>
        </div>
    </div>

</form>

<div class="bs-docs-example table-align pt-15" style="clear:both;">
    <table class="table table-striped table-align">
        <thead>
        <tr>
            <th>微课ID</th>
            <th>微课标题</th>
            <th>开始时间</th>
            <th>状态</th>
            <th>报名人数</th>
            <th>提问数</th>
            <th>礼物总值</th>
            <th>操作</th>
        </tr>
        </thead>
        {if count($list)>0}
        <tbody>
        {loop $list $k $v}
            <tr>
                <td>{$v['id']}</td>
                <td>{$v['title']}</td>
                <td>{$v['formatTime']}</td>
                <td>{$v['statusMsg']}</td>
                <td>{$v['join_num']}</td>
                <td>{$v['totalQuesNum']}</td>
                <td>{$v['totalGoldPrice']}</td>
                <td>
                    <!--{if $v['status'] == 0}-->
                        <!--<a href="?c=adminFlashBuy&a=addFlashBuy&flashId={$v['id']}">编辑</a>-->
                        <!--<a href="javascript:void(0);" id="delLog_{$v['id']}" ids="{$v['id']}" >删除</a>-->
                    <!--{/if}-->
                    {if $v['status'] == 0}
                        <a href="javascript:void(0);" id="overLog_{$v['id']}" ids="{$v['id']}" >取消</a>
                    {elseif $v['status']== 5}
                        进行中
                    {elseif $v['status']== 10}
                        已结束
                    {elseif $v['status']== -5}
                        已取消
                    {else}
                      未知状态
                    {/if}
                    <a href="?c=live_admin&a=addLive&liveId={$v['id']}">详情</a>
                    <a href="?c=live_admin&a=getGoldCostList&name={$v['title']}">消费汇总</a>
                </td>
            </tr>

        {/loop}
        <div id="res"></div>
        </tbody>
        {/if}
    </table>

</div>
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
{template footer}
<div class="bg" id="bgx"></div>
<div id="dialog" style="position: absolute; z-index: 1003;background-color:white; display: none;" >
    <div  style="margin:50px 100px;">
        <div class="controls">
            <div style="padding-left:20px;">确定操作？</div><br />
            <div style="text-align: center">
                <button class="btn btn-primary" id="ok" ids="">确定</button>
                <button class="btn btn-primary" id="close" >取消</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $("a[id^='overLog_']").on('click',function () {
        var _this = $(this), _ids = _this.attr('ids');
        $("#bgx").show();
        letDivCenter('#dialog');
        $('#ok').attr({ids:_ids, action:'?c=live_admin&a=ajaxDelLive'});
    })
    $('#ok').on('click',function(){
        var _this = $(this),ids=_this.attr('ids'), action=_this.attr('action');
        $.ajax({
            type:'POST',
            url:action,
            data:{liveId:ids},
            dataType:'json',
            success:function(d){
                if(d.status=='ok'){
                    alert(d.error_msg);
                    window.location.reload();
                }else{
                    $('#close').click();
                    alert(d.error_msg);
                }
            }
        })
    })
    $('#close').on('click',function(){
        $('#dialog').css('display','none');
        $("#bgx").fadeOut(300);
    })
    function letDivCenter(divName){
        var divObj = $(divName);
        var wWidth = $(document.body).width(),wHeight = $(window).height();
        var divWidth = divObj.width(),divHeight = divObj.height();
        divObj.css({'left':(wWidth-divWidth)/2+$(window).scrollLeft(),'top':(wHeight-divHeight)/2+$(window).scrollTop(),'display':'block'});
        $(window).bind('scroll resize',function(){
            $(divName).css({'left':(wWidth-divWidth)/2+$(window).scrollLeft(),'top':(wHeight-divHeight)/2+$(window).scrollTop()});
        });
    }

</script>